package mhwi.relics;

import basemod.abstracts.CustomRelic;
import com.megacrit.cardcrawl.actions.common.ApplyPowerAction;
import com.megacrit.cardcrawl.actions.utility.UseCardAction;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.core.AbstractCreature;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.helpers.ImageMaster;
import com.megacrit.cardcrawl.relics.AbstractRelic;
import mhwi.helper.ModHelper;
import mhwi.powers.LianQiPower;
import mhwi.powers.ShouDaoPower;

import static mhwi.constants.ResourcesConstant.EXTENSION_PNG;
import static mhwi.constants.ResourcesConstant.PATH_IMG_RELICS;

public class CangLanXingRelic extends CustomRelic {
    public static final String CLASS_NAME = CangLanXingRelic.class.getSimpleName();
    public static final String ID = ModHelper.makeId(CLASS_NAME);
    private static final String IMG_PATH = ModHelper.makeFileName(PATH_IMG_RELICS, CLASS_NAME, EXTENSION_PNG);
    private static final String OUTLINE_PATH = ModHelper.makeFileName(PATH_IMG_RELICS, CLASS_NAME, "_outline", EXTENSION_PNG);
    private static final RelicTier RELIC_TIER = RelicTier.STARTER;
    private static final LandingSound LANDING_SOUND = LandingSound.FLAT;

    public CangLanXingRelic() {
        super(ID, ImageMaster.loadImage(IMG_PATH), ImageMaster.loadImage(OUTLINE_PATH), RELIC_TIER, LANDING_SOUND);
    }

    public String getUpdatedDescription() {
        return this.DESCRIPTIONS[0];
    }

    public AbstractRelic makeCopy() {
        return new CangLanXingRelic();
    }

    @Override
    public void atBattleStart() {
        super.atBattleStart();
        AbstractCreature owner = AbstractDungeon.player;
        if(owner.getPower(ShouDaoPower.POWER_ID) == null) {
            AbstractDungeon.actionManager.addToBottom(new ApplyPowerAction(owner, owner, new ShouDaoPower(owner), 1));
        }
    }

    @Override
    public void onUseCard(AbstractCard card, UseCardAction action) {
        if (card.type == AbstractCard.CardType.ATTACK) {
            AbstractCreature owner = AbstractDungeon.player;
            AbstractDungeon.actionManager.addToBottom(new ApplyPowerAction(owner, owner, new LianQiPower(owner, 1), 1));

        }
    }
}
